#ifndef _FAT_H_
#define _FAT_H_

#include <stdint.h>
#include <stdbool.h>
#include "main.h"

#define CONCAT_1(a, b) a##b
#define CONCAT_0(a, b) CONCAT_1(a, b)
#define STATIC_ASSERT(e)                                        \
    enum                                                        \
    {                                                           \
        CONCAT_0(_static_assert_, __LINE__) = 1 / ((e) ? 1 : 0) \
    }

#define STORAGE_BLK_SIZ FLASH_PAGE_SIZE
#define STORAGE_BLK_NBR ((128 * 1024) / STORAGE_BLK_SIZ)

enum UPGRADE_STATUS
{
    UPGRADE_READY,
    UPGRADE_SUCCESS,
    UPGRADE_FAILED,
    UPGRADE_LARGE,
    UPGRADE_UNKNOWN,
    UPGREDE_DONE
};

extern enum UPGRADE_STATUS msd_UpStatus;

uint32_t FATWriteLBA(uint32_t block_no, uint8_t* data, uint16_t len);
uint32_t FATReadLBA(uint32_t block_no, uint8_t* data, uint16_t len);
uint32_t FATSetStatusFileName(const char* name);

#endif
